function [ROI] = getROI_ARGUS(ARGUS_Filename)

% This will load ROI values for each phase time, multiple ROI's are supported.
% Coordinates are exported in units of pixels

% *INPUT*
% ARGUS_Filename    : self explanatory

% *OUTPUT*
% ROI      : ROI(coordinate,'x' or 'y',timestep,numReg)
% timestep : number of timesteps
% numReg   : number of regions

% AJB, 9/27/2007

timestep   = 0;
anotherIm  = 1;
anotherReg = 1;
ROI = 0;

% Load Argus data
fid = fopen(ARGUS_Filename);

%% Search for, and find the number of images and the number of Regions
while anotherReg

    tline = fgetl(fid);
    
    if strfind(tline,' Img    TT   RefVel')
        
        %skip some lines once the tag 'Img    TT   RefVel' is found 
        tline    = fgetl(fid);
        tline    = fgetl(fid);

        % Find the total number of images in the scan sequence
        while anotherIm
            
            timestep = str2double(tline(1:4));
            tline    = fgetl(fid);
            if isempty(tline)
                anotherIm = 0;
            end
            
        end
        
        for i = 1:6
            tline = fgetl(fid);
        end  % skip 6 lines
        
        % count the number of regions
        while anotherReg
            
            numReg = str2double(tline(1:4));
            tline   = fgetl(fid);
            if isempty(tline)
                anotherReg = 0;
            end
            
        end
    
    end

end

%% Find flow contours tag
while 1

    tline = fgetl(fid);
    if strfind(tline,'Flow contours:'),break, end
        
end

tline = fgetl(fid); % start at the first region coordinates
tline = fgetl(fid);

for i=1:timestep
    
    for j = 1:numReg
        
        StartIndex = find(tline == '(');
        EndIndex   = find(tline == ')');
        CommaIndex = find(tline == ',');
        
        for k = 1:1:length(StartIndex)
           
            % Get current point string - Comma Delimited            
            ROI(k,2,i,j) = str2double(tline(StartIndex(k)+1:CommaIndex(k)-1))+1;
            ROI(k,1,i,j) = str2double(tline(CommaIndex(k)+1:EndIndex(k)-1))+1;
             
        end
        
        tline = fgetl(fid);
        
    end
    
    tline = fgetl(fid);
    tline = fgetl(fid);
       
end

fclose(fid);